﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using RenChangYou.Common;
using RenChangYou.BLL;
using DaoYou.Web.Guider.Account;

namespace DaoYou.Web.Account
{
    public partial class ChangePassword : PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void btn_changPwd_Click(object sender, EventArgs e)
        {
            try
            {
                string oldPwd = txt_pwd.Value.Trim();
                string newpwd = txt_newPwd.Value.Trim();
                string repwd = txt_rePwd.Value.Trim();
                //int userid = Uid;

                if (!newpwd.Equals(repwd))//密码确认密码输入错误
                {
                    Common.AlertMessageAndRedirect("确认密码和密码不一致，请重新输入！", ResolveUrl("~/Account/ChangePassword.aspx"));
                    return;
                }

                DY_User user_bll = new DY_User();
                int result = user_bll.UpdPwd(Account, oldPwd, newpwd);
                if (result > 1)
                {
                    Common.AlertMessageAndRedirect("修改密码成功！", ResolveUrl("~/Account/ChangePasswordSuccess.aspx"));
                }
                else
                {
                    Common.AlertMessageAndRedirect("修改密码失败！", ResolveUrl("~/Account/ChangePassword.aspx"));
                    
                }
                
            }
            catch
            {
                Common.AlertMessageAndRedirect("系统错误！", ResolveUrl("~/Account/ChangePassword.aspx"));
            }
        }
    }
}
